package com.xxx.auth.common.interceptor;

import jakarta.servlet.*;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

@Configuration
public class RequestFilter implements Filter {

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        HttpServletRequest httpRequest = (HttpServletRequest) request;
        if (httpRequest.getRequestURI().equals("/authentication/v1/user/register") ||
                httpRequest.getRequestURI().equals("/authentication/v1/application/create")) {
            chain.doFilter(request, response);
        } else {
            ServletRequest requestWrapper = new RequestWrapper(httpRequest);
            chain.doFilter(requestWrapper, response);
        }
    }
}